package com.nbsaas.boot.order.data.entity;

import com.nbsaas.boot.code.annotation.*;
import com.nbsaas.boot.jpa.data.entity.AbstractEntity;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Table;
import lombok.Data;
import org.hibernate.annotations.Comment;

import java.math.BigDecimal;
import java.time.LocalDateTime;

@CreateByUser
@ComposeView
@Data
@FormAnnotation(title = "订单发票", model = "订单发票")
@Entity
@Table(name = "bs_order_invoice")
@Comment("订单发票表")
public class OrderInvoice extends AbstractEntity {

    @Comment("订单ID")
    @FormField(title = "订单ID", sortNum = "1", grid = true, required = true)
    @Column(name = "order_id", nullable = false)
    private Long orderId;

    @Comment("订单编号")
    @FormField(title = "订单编号", sortNum = "2", grid = true, required = true)
    @Column(name = "order_no", nullable = false, length = 64)
    private String orderNo;

    @Comment("发票单号")
    @FormField(title = "发票单号", sortNum = "3", grid = true, required = true)
    @Column(name = "invoice_no", nullable = false, unique = true, length = 64)
    private String invoiceNo;

    @Comment("发票类型")
    @FormField(title = "发票类型", sortNum = "4", grid = true, type = InputType.select)
    @Column(name = "invoice_type", nullable = false)
    private Integer invoiceType;

    @Comment("发票抬头")
    @FormField(title = "发票抬头", sortNum = "5", grid = true, required = true)
    @Column(name = "invoice_title", nullable = false, length = 100)
    private String invoiceTitle;

    @Comment("纳税人识别号")
    @FormField(title = "纳税人识别号", sortNum = "6", grid = true)
    @Column(name = "tax_number", length = 50)
    private String taxNumber;

    @Comment("发票内容")
    @FormField(title = "发票内容", sortNum = "7", grid = true, required = true)
    @Column(name = "invoice_content", nullable = false, length = 200)
    private String invoiceContent;

    @Comment("发票金额")
    @FormField(title = "发票金额", sortNum = "8", grid = true, type = InputType.el_input_number)
    @Column(name = "invoice_amount", nullable = false, precision = 10, scale = 2)
    private BigDecimal invoiceAmount;

    @Comment("税率")
    @FormField(title = "税率", sortNum = "9", grid = true, type = InputType.el_input_number)
    @Column(name = "tax_rate", nullable = false, precision = 5, scale = 2)
    private BigDecimal taxRate = BigDecimal.ZERO;

    @Comment("税额")
    @FormField(title = "税额", sortNum = "10", grid = true, type = InputType.el_input_number)
    @Column(name = "tax_amount", nullable = false, precision = 10, scale = 2)
    private BigDecimal taxAmount = BigDecimal.ZERO;

    @Comment("发票状态")
    @FormField(title = "发票状态", sortNum = "11", grid = true, type = InputType.select)
    @Column(name = "invoice_status", nullable = false)
    private Integer invoiceStatus = 0;

    @Comment("开具时间")
    @FormField(title = "开具时间", sortNum = "12", type = InputType.date, grid = true)
    @Column(name = "issue_time")
    private LocalDateTime issueTime;

    @Comment("寄送时间")
    @FormField(title = "寄送时间", sortNum = "13", type = InputType.date, grid = true)
    @Column(name = "send_time")
    private LocalDateTime sendTime;

    @Comment("收件人姓名")
    @FormField(title = "收件人姓名", sortNum = "14", grid = true)
    @Column(name = "receiver_name", length = 50)
    private String receiverName;

    @Comment("收件人电话")
    @FormField(title = "收件人电话", sortNum = "15", grid = true)
    @Column(name = "receiver_phone", length = 20)
    private String receiverPhone;

    @Comment("收件地址")
    @FormField(title = "收件地址", sortNum = "16", grid = true)
    @Column(name = "receiver_address", length = 200)
    private String receiverAddress;

    @Comment("快递公司")
    @FormField(title = "快递公司", sortNum = "17", grid = true)
    @Column(name = "express_company", length = 50)
    private String expressCompany;

    @Comment("快递单号")
    @FormField(title = "快递单号", sortNum = "18", grid = true)
    @Column(name = "express_no", length = 50)
    private String expressNo;

    @Comment("备注")
    @FormField(title = "备注", sortNum = "19", type = InputType.textarea)
    @Column(name = "remark", length = 200)
    private String remark;
} 